// .txt

beginzonescript;

variables;

short im_hostile = 0;
short last_abil;
short counter = 0;
short set_ter1 = 0;
short i;

body;

beginstate INIT_STATE;
	last_abil = get_current_tick();

	set_name(2707,"Cabieala");
	set_name(30001,"Mine Worker");

	set_name(2722,"Howling Dire Wolf");
	set_boss_level(2722,1);
	add_ability(2722,10,87,0);
	
	set_name(2711,"Swamp Zombie");
	add_ability(2711,10,89,0);
	set_coloradj(2711,2);
	set_name(2712,"Swamp Zombie");
	add_ability(2712,10,89,0);
	set_coloradj(2712,2);
	set_name(30006,"Swamp Zombie");
	add_ability(30006,10,89,0);
	set_coloradj(30006,2);
	
	set_name(30008,"Rat King");
	set_boss_level(30008,2);
	change_max_health(30008,100);
	set_coloradj(30008,1);
	add_ability(30008,3,76,0);
	add_ability(2735,4,110,0);
	add_ability(2737,4,110,0);

	set_attack_range(30002,4);
	set_attack_range(30003,4);
	set_attack_range(30005,4);
	set_attack_range(30006,2);
	set_attack_range(30007,4);

	set_boss_level(2760,1);

//	add_ability(short which_char_or_group,short which_slot,short which_ability,0);

//	if (is_town_clear(ME))
//		clean_up_town();

	if (gf(27,11) > 0) {
		sf(27,3,1);
		erase_char(30002);
		erase_char(30003);
		erase_char(30004);
		erase_char(30005);
		erase_char(30006);
		erase_char(30007);
		erase_char(30008);
		
		if (gf(27,22) == 0)
			kill_object(2,1);
		}
	if (gf(27,11) == 0) 
		sf(27,4,0);
	if (gf(27,12) > 0) {
		erase_char(30011);
		}
		else erase_char(30013);
		
	if (gf(27,15) > 0)
			kill_object(24,1);
	break;

beginstate EXIT_STATE;

break;

beginstate START_STATE;
	if ((set_ter1 == 0) && (gf(27,3) > 0)) {
		set_ter1 = 1;
		set_terrain(0,46,22,0);
		set_terrain(0,47,22,0);
		set_terrain(0,48,22,0);
		set_terrain(0,46,23,0);
		set_terrain(0,47,23,0);
		set_terrain(0,48,23,0);
		}
	
	if ((is_talking() == FALSE) && (gf(27,11) == 0) && (num_chars_in_group(8) == 0)) {
		sf(27,11,1);
		begin_talk_mode(13);
		}
		
	// if (gf(,) == 0) {
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(2707,"I lead here.");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(2707,"You are welcome.");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(2707,"Sit and eat.");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(2707,"I can talk.");

	//	}

	//if (gf(,) < 2) {
	//	inc_flag(,,1);
	//	if (gf(,) == 2)
	//		begin_talk_mode();
	//	}

	if (((is_combat()) && (tick_difference(last_abil,get_current_tick()) > 0)) || ((is_town()) && (tick_difference(last_abil,get_current_tick()) > 4))) {
		last_abil = get_current_tick();
		if ((gf(27,4) > 0) && (gf(27,11) == 0) && (on_which_layer() == 0) && (party_dist_to_spot(43,13) <= 10)) {
			i = get_ran(1,0,7);
			if (char_ok(2739 + i) == FALSE) {
				spawn_creature(2739 + i);
				set_summon_level(2739 + i,1);
				}
			//i = get_ran(1,0,7);
			//if (char_ok(2739 + i) == FALSE) {
			//	spawn_creature(2739 + i);
		//		set_summon_level(2739 + i,1);
			//	}
			if (difficulty() > 1) {
				i = get_ran(1,0,7);
				if (char_ok(2739 + i) == FALSE) {
					spawn_creature(2739 + i);
					set_summon_level(2739 + i,1);
					}
				}
			}
		}
break;

beginstate 10;
	sf(27,20,1);
break;

beginstate 11;
break;

beginstate 12;
break;

beginstate 13;
break;

//	print_str("");
//	set_terrain_string_range(".",1);
//	set_terrain_string_range("The sign says - .",1);
